//有效的数独
//测试链接：https://leetcode.cn/problems/valid-sudoku/
public class IsValidSudoku {
    public boolean isValidSudoku(char[][] board) {
        boolean[][] row = new boolean[9][10];
        boolean[][] col = new boolean[9][10];
        boolean[][][] grid = new boolean[3][3][10];

        for(int i = 0; i < 9; i++) {
            for (int j = 0; j < 9; j++) {
                if(board[i][j] == '.') continue;

                int num = board[i][j] - '0';
                if(row[i][num] || col[j][num] || grid[i/3][j/3][num]) {
                    return false;
                }
                row[i][num] = true;
                col[j][num] = true;
                grid[i/3][j/3][num] = true;
            }
        }

        return true;
    }
}
